package com.atguigu.dao.impl;

import com.atguigu.bean.User;
import com.atguigu.dao.BaseDao;
import com.atguigu.dao.UserDao;

/**
 * @Author zhangchunsheng
 * @CreateTime: 2025/01/08
 */
public class  UserDaoImpl extends BaseDao implements UserDao {


    @Override
    public User selectUserByUsernameAndPassword(User user) throws Exception {
        String sql = "SELECT * FROM sys_user WHERE username = ? AND `password` = ?";
        return queryBean(User.class,sql,user.getUsername(),user.getPassword());
    }

    @Override
    public void insertUser(User user) throws Exception {
        String sql = "INSERT INTO sys_user(username,PASSWORD,nickname) VALUES(?,?,?)";
        update(sql,user.getUsername(),user.getPassword(),user.getNickname());
    }

    @Override
    public void updatePwd(User user) throws Exception {
        String sql = "update sys_user set password = ? where username = ?";
        update(sql,user.getPassword(),user.getUsername());
    }

}
